package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Result;
import com.hksj.Intelligentmanagement.dto.DicInfoDTO;
import com.hksj.Intelligentmanagement.service.DicInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "字典明细管理")
@RestController
@RequestMapping("/api/dicInfo")
public class DicInfoController {
    @Autowired
    private DicInfoService dicInfoService;

    @ApiOperation(value = "新增字典明细")
    @PostMapping("/addDicInfo")
    public Result addDicInfo(@RequestBody DicInfoDTO dicInfoDTO) {
        return dicInfoService.addDicInfo(dicInfoDTO);
    }

    @ApiOperation(value = "删除字典明细")
    @DeleteMapping("/deleteDicInfo/{id}")
    public Result deleteDicInfo(@PathVariable("id") String id) {
        return dicInfoService.deleteDicInfo(id);
    }

    @ApiOperation(value = "更新字典明细")
    @PutMapping("/updateDicInfo")
    public Result updateDicInfo(@RequestBody DicInfoDTO dicInfoDTO) {
        return dicInfoService.updateDicInfo(dicInfoDTO);
    }

    @ApiOperation(value = "根据id查询单个字典明细")
    @GetMapping("/queryDicInfoById/{id}")
    public Result queryDicInfoById(@PathVariable("id") String id) {
        return dicInfoService.queryDicInfoById(id);
    }

    @ApiOperation(value = "根据字典类型id查询所有字典明细")
    @PostMapping("/queryDicInfoAllByTypeId")
    @ResponseBody
    public Result queryDicInfoAllByTypeId(String typeId) {
        return Result.data(dicInfoService.queryDicInfoAllByTypeId(typeId));
    }
}
